package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.List;

/**
 * <p><b>SysDictData Description:</b> SysDictData po类 ; 字典数据表</p>
 * @author 窦再兴
 * <p><b>DATE</b> 2019-08-13 11:02:01</p>
 */
@Data
@Entity
@Table(name = "pc_sys_dict_data")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysDictData implements java.io.Serializable {


	private static final long serialVersionUID = -7783589462792093439L;
	/**
	 * <b>Fields</b> id : 字典id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_SYS_DICT_DATA_ID")
	@SequenceGenerator(name = "SEQ_SYS_DICT_DATA_ID", sequenceName = "SEQ_SYS_DICT_DATA_ID",allocationSize = 1)
	private Long id;
	
	/**
	 * <b>Fields</b> parentId : 父级编号
	 */
	@Column(name = "parent_id")
	private Long parentId;
	
	/**
	 * <b>Fields</b> parentIds : 所有父级编号，可用于做数据权限
	 */
	@Column(name = "parent_ids")
	private String parentIds;
	
	/**
	 * <b>Fields</b> sort : 排序号  升序:asc 降序:desc
	 */
	private Integer sort;
	
	/**
	 * <b>Fields</b> isleaf : 是否最末级 1：是 0：否
	 */
	@Column(name = "last_leaf")
	private String lastLeaf;
	
	/**
	 * <b>Fields</b> label : 字典标签
	 */
	private String label;
	
	/**
	 * <b>Fields</b> value : 字典键值
	 */
	private String value;
	
	/**
	 * <b>Fields</b> type : 字典类型
	 */
	private String type;
	
	/**
	 * <b>Fields</b> description : 字典描述
	 */
	private String description;
	
	/**
	 * <b>Fields</b> createdBy : 创建者
	 */
	@Column(name = "created_by")
	private String createdBy;
	
	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private java.time.LocalDateTime createdTime;
	
	/**
	 * <b>Fields</b> updatedBy : 更新者
	 */
	@Column(name = "updated_by")
	private String updatedBy;
	
	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private java.time.LocalDateTime updatedTime;
	
	/**
	 * <b>Fields</b> remarks : 备注信息
	 */
	private String remarks;

	/**
	 * <b>Fields</b> status : 状态（0正常 1删除 2停用）
	 */
	private Integer deleted;

	@Transient
	private List<SysDictData> children;

	public static void putTimeAndUser(SysDictData sysDictData) {
		if (sysDictData.id == null) {
			sysDictData.setCreatedBy(com.wondertek.poms.common.constant.CurrentUser.currUserName());
			sysDictData.setCreatedTime(java.time.LocalDateTime.now());
		}
		sysDictData.setUpdatedBy(com.wondertek.poms.common.constant.CurrentUser.currUserName());
		sysDictData.setUpdatedTime(java.time.LocalDateTime.now());
	}
}